problem with batch file

Hey guys,

i've written a script that writes some object-information of chosen objects in some modules in a *.csv file.
No big deal as yet..

When i run it in DOORS it works as assumed (informatian are written to *.csv - no error(s)), but when i run it with a batch file i got a few dxl errors, here the script and the error:
 

// DECLARATION
 
Stream configFile = read "d:\\CTRS_Config.csv"
 
exportFile = write("d:\\CTRS_Export.csv")
 
string targetModule
 
string modulePrefix
string absoluteNumber
string objectHeading
string reqiredReleaseMirror
string effortEstimation
 
 
// READ CONFIG FILE
 
for (configFile >> targetModule; ! end configFile; configFile >> targetModule)
{
    //CHECK IF TARGET IS A MODULE
 
        if (!module(targetModule))
        {
                errorBox "Target  '" targetModule "'  is not a Module!\nPlease check Config-File"
                halt
        }
 
        ModName_ tar = module(targetModule)
        ModuleVersion modver = moduleVersion(tar)
        Module m = load(modver, false)
 
        modulePrefix = m."Prefix"
 
        Object o
 
        for o in m do
        {
                absoluteNumber       = o."Absolute Number"
                objectHeading        = o."Object Heading"
                reqiredReleaseMirror = o."HB_Required_Release_Mirror"
                effortEstimation     = o."HB_Effort_Estimation"               
        
 
                // WRITE TO CTRS_Export.csv
        
                exportFile << "\042" fullName(m) "\042,\042" modulePrefix "\042,\042" absoluteNumber "\042,\042" objectHeading "\042,\042" reqiredReleaseMirror "\042,\042" effortEstimation "\042\n" 
 
        }
 
 
}
 
print "\nDone!"

 


And the errors:

-E- DXL: <Line:57> incorrect arguments for (=)
-E- DXL: <Line:60> incorrect arguments for (.)
-E- DXL: <Line:60> incorrect arguments for (=)
-E- DXL: <Line:68> incorrect arguments for function (find)
-E- DXL: <Line:68> incorrectly concatenated tokens
-I- DXL: all done with 5 errors and 0 warnings
DXL contains 5 errors-E- DXL: <Line:57> incorrect arguments for (=)
-E- DXL: <Line:60> incorrect arguments for (.)
-E- DXL: <Line:60> incorrect arguments for (=)
-E- DXL: <Line:68> incorrect arguments for function (find)
-E- DXL: <Line:68> incorrectly concatenated tokens
-I- DXL: all done with 5 errors and 0 warnings
DXL contains 5 errors
Done!
Press return to exit DOORS.

Can someone tell me whats wrong? I dont get it..

Regards,
Manuel

 


ManuelFelger - Mon Aug 10 11:05:04 EDT 2009

Re: problem with batch file
dpechacek - Mon Aug 10 12:00:43 EDT 2009

The code you have attached is only 53 lines long. So unless you left something out, I can't tell.

A potential issue I see is that Absolute Number is an integer. You need to append the empty string after the name.

AAI Services, Textron
dpechacek@aai.textron.com
David.Pechacek@gmail.com

Re: problem with batch file
llandale - Mon Aug 10 13:40:29 EDT 2009

Presumably the DXL that you are showing is placed in the "-b ..." command line switch.

I see you get two sets of identical errors suggesting the offending DXL is running twice. I also see that the file name of the offending errors is NOT displayed. The DXL that has the Errors is not the DXL that you are running and shown.

This leads me to suspect that the user name mentioned in your Batch command line is not the same user that you are testing your DXL with. [1] Some of the modules have a different default view with Layouts or displayed Attr-DXL, and these have the errors in their DXL. This has the feel of an old Layout that does this: othero = target(l) without defining othero as an 'Object', and it gets defined as a ModVer_ handle, and that code never runs for you because you never use the view in question. [2] Its also possible that YOU may have some Current-User 'addins' defined for you client that the other user does not have.

I would print the name of the module before 'loading' it in order to see which module is causing the errors.

  • Louie

PS. I'm feeling grouchy and feel like nit-picking:

Yes, you should turn your absno into a string: absoluteNumber = o."Absolute Number" "". I wonder why you are not getting an error.

Your 'for o in m' loop only retrieves currently displayed objects, which is a function of the default view. I doubt that's really what you want. Perhaps use 'for o in entire m' loop, followe by 'if (isDeleted(o)) continue'.

You should define 'ExportFile' as a 'Stream', and close that stream before you halt and before the DXL ends. Turn off AutoDeclare, sheeeesh.

Check for null 'm'; maybe the module exists but is deleted.

You may want to export "\",\"" (double quote, comma, double quote) instead of "\042,\042" since its easier to understand; at least for those of use that don't do octal-decimal conversions and don't know that Ascii #34 is a double-quote.
I wonder what happens when your displayed attr values contain an EOL; it will probably be interpreted by Excel when you open the CSV as end of line.

I wonder what happens when your displayed attr values contain a double-quote followed by a comma.

Re: problem with batch file
ManuelFelger - Wed Aug 12 10:43:09 EDT 2009

llandale - Mon Aug 10 13:40:29 EDT 2009
Presumably the DXL that you are showing is placed in the "-b ..." command line switch.

I see you get two sets of identical errors suggesting the offending DXL is running twice. I also see that the file name of the offending errors is NOT displayed. The DXL that has the Errors is not the DXL that you are running and shown.

This leads me to suspect that the user name mentioned in your Batch command line is not the same user that you are testing your DXL with. [1] Some of the modules have a different default view with Layouts or displayed Attr-DXL, and these have the errors in their DXL. This has the feel of an old Layout that does this: othero = target(l) without defining othero as an 'Object', and it gets defined as a ModVer_ handle, and that code never runs for you because you never use the view in question. [2] Its also possible that YOU may have some Current-User 'addins' defined for you client that the other user does not have.

I would print the name of the module before 'loading' it in order to see which module is causing the errors.

  • Louie

PS. I'm feeling grouchy and feel like nit-picking:

Yes, you should turn your absno into a string: absoluteNumber = o."Absolute Number" "". I wonder why you are not getting an error.

Your 'for o in m' loop only retrieves currently displayed objects, which is a function of the default view. I doubt that's really what you want. Perhaps use 'for o in entire m' loop, followe by 'if (isDeleted(o)) continue'.

You should define 'ExportFile' as a 'Stream', and close that stream before you halt and before the DXL ends. Turn off AutoDeclare, sheeeesh.

Check for null 'm'; maybe the module exists but is deleted.

You may want to export "\",\"" (double quote, comma, double quote) instead of "\042,\042" since its easier to understand; at least for those of use that don't do octal-decimal conversions and don't know that Ascii #34 is a double-quote.
I wonder what happens when your displayed attr values contain an EOL; it will probably be interpreted by Excel when you open the CSV as end of line.

I wonder what happens when your displayed attr values contain a double-quote followed by a comma.

first of all thank you for your reply!

I've tested it again and again with your notes like turning absoluteNumber into a string, run the batch with my username and so on but it didnt work..

A workmate told me he had the same problem when he declared a variable named "targetModule" and ran the script with a batch.
I replaced "targetModule" by "targetModule1" and the script also worked as batch.. dont ask why !?

The problem with the EOL did i solve with this function:

string myString = "\nword\nword\n\nword\n"
 
string deleteAllEOL(string stringToClear)
{
    bool a
        string sub = "\n"
        int offset
        int length1
        bool matchCase = true
        bool reverse = true
 
        string s1
        string s2
        string snew = ""
 
        a = findPlainText(stringToClear, sub, offset, length1, matchCase, reverse)
 
        for (a == true)
        {
                s1 = stringToClear[0:offset-1]
                s2 = stringToClear[offset+1:(length(stringToClear))]
 
                stringToClear = s1 s2
 
                a = findPlainText(stringToClear, sub, offset, length1, matchCase, reverse)
        }
 
        return stringToClear
}
 
 
string newString = deleteAllEOL(myString)
 
print "newString: " newString ""

 


So i'm happy for the moment, although i dont know why i cant name a variable "targetModule" :-)

Regards,
Manuel

 

Re: problem with batch file
llandale - Wed Aug 12 13:24:15 EDT 2009

ManuelFelger - Wed Aug 12 10:43:09 EDT 2009

first of all thank you for your reply!

I've tested it again and again with your notes like turning absoluteNumber into a string, run the batch with my username and so on but it didnt work..

A workmate told me he had the same problem when he declared a variable named "targetModule" and ran the script with a batch.
I replaced "targetModule" by "targetModule1" and the script also worked as batch.. dont ask why !?

The problem with the EOL did i solve with this function:

string myString = "\nword\nword\n\nword\n"
 
string deleteAllEOL(string stringToClear)
{
    bool a
        string sub = "\n"
        int offset
        int length1
        bool matchCase = true
        bool reverse = true
 
        string s1
        string s2
        string snew = ""
 
        a = findPlainText(stringToClear, sub, offset, length1, matchCase, reverse)
 
        for (a == true)
        {
                s1 = stringToClear[0:offset-1]
                s2 = stringToClear[offset+1:(length(stringToClear))]
 
                stringToClear = s1 s2
 
                a = findPlainText(stringToClear, sub, offset, length1, matchCase, reverse)
        }
 
        return stringToClear
}
 
 
string newString = deleteAllEOL(myString)
 
print "newString: " newString ""

 


So i'm happy for the moment, although i dont know why i cant name a variable "targetModule" :-)

Regards,
Manuel

 

You are SURE it yes works with "targetModule1" but not with name "targetModule"? Very strange. Don't see any 'targetModule' in the doors.exe and there appears to be no such variable nor function defined in the GUI top context nor the Batch top context. I can run a batch with variable "targetModule".

  • Louie